using Avalonia.Collections;
using CommunityToolkit.Mvvm.ComponentModel;

namespace welog.core.model;


/// <summary>
/// 主要是绑定日志文件的树形结构，后续可以作为独立的库为上层应用提供数据源
/// </summary>
public partial class LogTreeNode: ObservableObject
{
    [ObservableProperty] private string _name;

    [ObservableProperty] private string _value;

    public List<string> ChildrenFile { get; set; } = new List<string>();

    public AvaloniaList<LogTreeNode> ChildrenDir { get; set; } = new AvaloniaList<LogTreeNode>();

    /// <summary>
    /// 获取当前日期 主要显示在当前要编辑的右上角
    /// </summary>
    /// <returns></returns>
    public string GetCurrentDateString()
    {
        var valueList = this.Value.Split("\\");
        var valueLen = valueList.Length;
        return $"{valueList[valueLen - 3]}-{valueList[valueLen - 2]}-{valueList[valueLen - 1]}";
    }

    public string DayOfWeek()
    {
        var currentDate = Convert.ToDateTime(this.GetCurrentDateString());
        string[] Day = new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
        string week = Day[Convert.ToInt32(currentDate.DayOfWeek.ToString("d"))];
        return week;
    }
}